home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Alles Voor Internet / Tout Pour Internet
/
alles voor internet.iso
/
MacInternet™
/
Telnet
/
NCSA
/
tn3270 2.3d26 source
/
MPW changes
/
CIncludes
/
Sound.h
Wrap
Text File
|
1990-09-25
|
6KB
|
280 lines
/************************************************************
Created: Saturday, September 16, 1989 at 5:42 PM
Sound.h
C Interface to the Macintosh Libraries
Copyright Apple Computer, Inc. 1986-1989
All rights reserved
************************************************************/
#ifndef __SOUND__
#define __SOUND__
#ifndef __TYPES__
#include <Types.h>
#endif
#define swMode -1
#define ftMode 1
#define ffMode 0
#define synthCodeRsrc 'snth'
#define soundListRsrc 'snd '
/* synthesizer numbers for SndNewChannel */
#define noteSynth 1 /*note synthesizer*/
#define waveTableSynth 3 /*wave table synthesizer*/
#define sampledSynth 5 /*sampled sound synthesizer*/
#define midiSynthIn 7 /*MIDI synthesizer in*/
#define midiSynthOut 9 /*MIDI synthesizer out*/
/* Param2 values */
#define midiInitChanFilter 0x10 /*set to initialize a MIDI channel*/
#define midiInitRawMode 0x100 /*set to send raw MIDI data*/
#define twelthRootTwo 1.05946309434
#define infiniteTime 0x7FFFFFFF
/* command numbers for SndDoCommand */
#define nullCmd 0
#define initCmd 1
#define freeCmd 2
#define quietCmd 3
#define flushCmd 4
#define waitCmd 10
#define pauseCmd 11
#define resumeCmd 12
#define callBackCmd 13
#define syncCmd 14
#define emptyCmd 15
#define tickleCmd 20
#define requestNextCmd 21
#define howOftenCmd 22
#define wakeUpCmd 23
#define availableCmd 24
#define versionCmd 25
#define scaleCmd 30
#define tempoCmd 31
#define noteCmd 40
#define restCmd 41
#define freqCmd 42
#define ampCmd 43
#define timbreCmd 44
#define waveTableCmd 60
#define phaseCmd 61
#define soundCmd 80
#define bufferCmd 81
#define rateCmd 82
#define midiDataCmd 100
#define setPtrBit 0x8000
#define stdQLength 128
#define dataPointerFlag 0x8000
#define initChanLeft 2 /*left stereo channel */
#define initChanRight 3 /*right stereo channel*/
#define initChan0 4 /*channel 0 - wave table only*/
#define initChan1 5 /*channel 1 - wave table only*/
#define initChan2 6 /*channel 2 - wave table only*/
#define initChan3 7 /*channel 3 - wave table only*/
#define initSRate22k 0x20 /*22k sampling rate*/
#define initSRate44k 0x30 /*44k sampling rate*/
#define initMono 0x80 /*monophonic channel*/
#define initStereo 0xC0 /*stereo channel*/
#define firstSoundFormat 1 /*first and only version we can deal with*/
typedef unsigned char FreeWave[30001];
typedef long Time; /* in half milliseconds */
typedef unsigned char Wave[256];
typedef Wave *WavePtr;
struct FFSynthRec {
short mode;
Fixed count;
FreeWave waveBytes;
};
typedef struct FFSynthRec FFSynthRec;
typedef FFSynthRec *FFSynthPtr;
struct Tone {
short count;
short amplitude;
short duration;
};
typedef struct Tone Tone;
typedef Tone Tones[5001];
struct SWSynthRec {
short mode;
Tones triplets;
};
typedef struct SWSynthRec SWSynthRec;
typedef SWSynthRec *SWSynthPtr;
struct FTSoundRec {
short duration;
Fixed sound1Rate;
long sound1Phase;
Fixed sound2Rate;
long sound2Phase;
Fixed sound3Rate;
long sound3Phase;
Fixed sound4Rate;
long sound4Phase;
WavePtr sound1Wave;
WavePtr sound2Wave;
WavePtr sound3Wave;
WavePtr sound4Wave;
};
typedef struct FTSoundRec FTSoundRec;
typedef FTSoundRec *FTSndRecPtr;
struct FTSynthRec {
short mode;
FTSndRecPtr sndRec;
};
typedef struct FTSynthRec FTSynthRec;
typedef FTSynthRec *FTSynthPtr;
struct SndCommand {
unsigned short cmd;
short param1;
long param2;
};
typedef struct SndCommand SndCommand;
typedef struct ModifierStub *ModifierStubPtr;
typedef struct SndChannel *SndChannelPtr;
typedef pascal void (*SndCompletionProcPtr)(void);
typedef pascal void (*SndModifierProcPtr)(SndChannelPtr chan, SndCommand *cmd, ModifierStubPtr mod);
typedef pascal void (*SndCallBackProcPtr)(SndChannelPtr chan, SndCommand cmd);
struct SndChannel {
struct SndChannel *nextChan;
ModifierStubPtr firstMod;
SndCallBackProcPtr callBack;
long userInfo;
Time wait; /*The following is for internal Sound Manager use only.*/
SndCommand cmdInProgress;
short flags;
short qLength;
short qHead; /*next spot to read or -1 if empty*/
short qTail; /*next spot to write = qHead if full*/
SndCommand queue[stdQLength];
};
typedef struct SndChannel SndChannel;
struct ModifierStub {
struct ModifierStub *nextStub;
SndModifierProcPtr code;
long userInfo;
Time count;
Time every;
char flags;
char hState;
};
typedef struct ModifierStub ModifierStub;
struct SoundHeader {
Ptr samplePtr; /*if NIL then samples are in sampleArea*/
unsigned long length;
Fixed sampleRate;
unsigned long loopStart;
unsigned long loopEnd;
short baseNote;
char sampleArea[1];
};
typedef struct SoundHeader SoundHeader;
typedef SoundHeader *SoundHeaderPtr;
struct ModRef {
unsigned short modNumber;
long modInit;
};
typedef struct ModRef ModRef;
struct SndListResource {
short format;
short numModifiers;
ModRef modifierPart[1]; /*This is a variable length array*/
short numCommands;
SndCommand commandPart[1]; /*This is a variable length array*/
char dataPart[1]; /*This is a variable length array*/
};
typedef struct SndListResource SndListResource;
typedef SndListResource *SndListPtr;
/* User callable routines */
pascal void SetSoundVol();
pascal void GetSoundVol();
pascal void StartSound();
pascal void StopSound();
pascal Boolean SoundDone();
pascal OSErr SndDoCommand(chan, cmd, noWait)
SndChannelPtr chan;
SndCommand * cmd;
Boolean noWait;
extern 0xA803;
pascal OSErr SndDoImmediate(chan, cmd)
SndChannelPtr chan;
SndCommand * cmd;
extern 0xA804;
pascal OSErr SndAddModifier(chan, modifier, id, init)
SndChannelPtr chan;
ProcPtr modifier;
short id;
long init;
extern 0xA802;
pascal OSErr SndNewChannel(chanVar, synth, init, userRoutine)
SndChannelPtr * chanVar;
short synth;
long init;
ProcPtr userRoutine;
extern 0xA807;
pascal OSErr SndDisposeChannel(chan, quietNow)
SndChannelPtr chan;
Boolean quietNow;
extern 0xA801;
pascal OSErr SndPlay(chan, sndHdl, async)
SndChannelPtr chan;
Handle sndHdl;
Boolean async;
extern 0xA805;
pascal OSErr SndControl(id, cmdVar)
short id;
SndCommand * cmdVar;
extern 0xA806;
#endif